package com.example.demo;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class App {

    private ApplicationContext applicationContext;
    public App(){
        this.applicationContext = new ClassPathXmlApplicationContext("MiniApplicationContext.xml");
    }

    public void createSimpleBean(){
        MyBean simpleBean = (MyBean) applicationContext.getBean("simpleBean");
        simpleBean.hello();
    }

    public void createInitBean(){
        MyBean InitBean = (MyBean) applicationContext.getBean("initBean");
        InitBean.hello();

    }

    public void createFactoryBean(){
        MyBean factoryBean = (MyBean) applicationContext.getBean("factoryBean");
        factoryBean.hello();
    }

    public void createDynamicFactoryBean(){
        MyBean dynamicBean = (MyBean) applicationContext.getBean("dynamicFactoryBean");
        dynamicBean.hello();
    }

    public void createBeanWithSetInjection(){
        MyBean InjectionBean = (MyBean) applicationContext.getBean("setInjectionBean");
        InjectionBean.hello();
    }

    public void createBeanWithConsInjection(){
        MyBean InjectionBean = (MyBean) applicationContext.getBean("consInjectionBean");
        InjectionBean.hello();
    }

}
